package com.gilight.base.controller.uiapp;

import com.gilight.base.base.ResultEntity;
import com.gilight.base.base.exception.ServiceException;
import com.gilight.base.uiapp.category.CategoryService;
import com.gilight.base.uiapp.product.ProductService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author liken
 * 商品管理控制类
 */
@RestController
@RequestMapping("/web/app-category")
public class AppCategoryController {

    @Autowired
    private CategoryService categoryService;


    /**
     *
     * @return
     */
    @ApiOperation(value = "获取类目列表")
    @RequestMapping(value = "/category-list", method = {RequestMethod.GET})
    public ResultEntity categoryList(@RequestParam(defaultValue = "0",required = false)
                                     Integer isBaiHuo,Long zzjgId) {
        ResultEntity resultEntity = new ResultEntity();
        try {
            resultEntity.setData(categoryService.categoryList(isBaiHuo,zzjgId));
        } catch (ServiceException e) {
            e.printStackTrace();
        }
        return resultEntity;
    }

    @ApiOperation(value = "创建")
    @RequestMapping(value = "/get-category-family")
    public ResultEntity getCategoryFamily(Long categoryId) {
        ResultEntity resultEntity = new ResultEntity();

        try {
            resultEntity.setData(categoryService.getCategoryFamily(categoryId));
        } catch (ServiceException e) {
            e.printStackTrace();
        };
        return resultEntity;
    }
}
